package module.edittroop.view.editnewtrooppanel
{
	import com.darwin.darwinUI.controls.Button;
	import com.darwin.darwinUI.controls.Label;
	import com.darwin.darwinUI.controls.LabelButton;
	import com.darwin.darwinUI.core.UIComponent;
	import com.darwin.darwinUI.general.TextFieldFactory;
	import com.darwin.darwinUI.manager.UIManager;
	
	import flash.events.MouseEvent;
	import flash.utils.setTimeout;
	
	import module.edittroop.event.EditTroopEvent;
	import module.main.view.ResourceConst;

	public class ChoosePanel extends UIComponent
	{
		private var _backGround:UIComponent;
		private var _sureBtn:LabelButton;
		private var _chanelBtn:LabelButton;
		private var _uiTxtLabel:Label;
		private var _closeBtn:Button;
		public function ChoosePanel()
		{
			this.width = 367.4;
			this.height = 231.3;
			
			_backGround = new UIComponent;
			_backGround.backgroundAuto = false;
			_backGround.backgroundSkin = "EditTroop." + ResourceConst.EDIT_TROOP_BACKGROUND;
			_backGround.width = 367.4;
			_backGround.height = 231.3;
			
			_sureBtn = new LabelButton();
			_sureBtn.backgroundAuto = true;
			_sureBtn.backgroundSkin = "EditTroop." + ResourceConst.EDIT_TROOP_DISSOLVE_BUTTON;
			_sureBtn.height = 82.0;
			_sureBtn.width = 34.0;
			_sureBtn.addEventListener(MouseEvent.CLICK,clickHandler);
			
			_chanelBtn = new LabelButton();
			_chanelBtn.backgroundAuto = true;
			_chanelBtn.backgroundSkin = "EditTroop." + ResourceConst.EDIT_TROOP_CHANNEL_BUTTON;
			_chanelBtn.height = 82.0;
			_chanelBtn.width = 34.0;
			_chanelBtn.addEventListener(MouseEvent.CLICK,clickHandler);
			
			_uiTxtLabel = TextFieldFactory.getInstance().getLabel("create_request");
			_uiTxtLabel.text = "确定要解散该部队吗？";
			
			_closeBtn = new Button;
			_closeBtn.backgroundAuto = true;
			_closeBtn.backgroundSkin = "EditTroop." + ResourceConst.EDIT_TROOP_COLSE_BUTTON;
			_closeBtn.addEventListener(MouseEvent.CLICK,clickHandler);
			_closeBtn.height = 23.9;
			_closeBtn.width = 25.9;
			
//			setTimeout(setUiPosition,1000);
			setUiPosition();
		}
		private function clickHandler(e:MouseEvent):void
		{
			switch(e.currentTarget)
			{
				case _sureBtn:
					var choosePanelEvent:EditTroopEvent = new EditTroopEvent(EditTroopEvent.EDIT_DISSLOVE)
					this.dispatchEvent(choosePanelEvent);
					break;
				case _closeBtn:
					break;
				case _chanelBtn:
					break;
			}
			UIManager.getPopUpManager().removePopUp(this);
		}
		private function setUiPosition():void
		{
			addChild(_backGround);
			
			_sureBtn.x = (_backGround.width - _sureBtn.width) / 2 - _sureBtn.width -50;
			_sureBtn.y =3* _backGround.height / 4;
			_backGround.addChild(_sureBtn);
			
			_chanelBtn.x = (_backGround.width - _chanelBtn.width) / 2 + 50;
			_chanelBtn.y = _sureBtn.y;
			_backGround.addChild(_chanelBtn);
			
			_uiTxtLabel.x = (_backGround.width - _uiTxtLabel.width) / 2;
			_uiTxtLabel.y = _backGround.height / 2;
			_backGround.addChild(_uiTxtLabel);
			
			_closeBtn.x = _backGround.width - _closeBtn.width - 15;
			_closeBtn.y = 15;
			_backGround.addChild(_closeBtn);
		}
	}
}